{extend name="public/base" /}

{block name="pjax_container"}
<?php
    $titleTypeName = '员工视图';
?>
<style>
    input{
        margin-right:10px;
    }
    select{
        float: left;
        height:30px;
        margin-right:10px;
    }
    .input-group>p{
        padding-top: 10px;
        font-size: 16px;
        margin-right: 10px;
    }
    tr>td,th{
        text-align: center;
    }
    
.content-header>.breadcrumb>li{
    color: #999;
}
.content-header>.breadcrumb>.active{
    color: #666;
}
.content-header{
    height: 51px;
 
}
.btn-primary{
      background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 5px 10px; 
    line-height: 24px;
}
.box-primary{
  border-top-color: #ecf0f5 !important;
  border-top-width: 16px;
  
}
.btn-primary:hover{
     background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .9;
    border-radius: 6px !important; 
}
.delete-one{
    background-color: ff4141 !important;
    margin-left: 15px;
    border-radius: 6px;
}
.sreachs{
       background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 7px 15px;
    height: 34px !important; 
}

    .table-body {
        width: 554px;
        height: 470px;
        border-radius: 6px;
        background-color: #eee;
    }
    .table-left {
        margin-right: 2%;
        width: 49%;
        height: 100%;
        float: left;
        border: 1px solid #eee;
        background-color: #fff;
    }
    .modal-left {
        height: 100%;
    }
    .table-right {
        width: 49%;
        height: 100%;
        border: 1px solid #eee;
        float: left;
        background-color: #fff;
    }

</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>核查结算</li>
        <li class="active">{$titleTypeName}</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-tools" style="margin:5px;">
                    <form id="form1" action="{:search_url(['department_id', 'name', 'job_number', 'create_time'])}" method="GET" pjax-search="">
                        <div class="input-group input-group-sm" style="display: flex; align-items: center; flex-wrap: wrap;">
                            <input type="hidden" name="page" value="1" />
                            <p>组织机构:</p>
                            <div class="xyqk_input">
                                <input class="form-control department_id_name" name="department_id_name" value="{:input('get.department_id_name')}" placeholder="组织机构" autocomplete="off" style="width:200px;height:34px;">
                                <input class="department_id" name="department_id" value="{:input('get.department_id')}" type="hidden">
                                <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                            </div>

                            <!-- <select class="select2" name="department_id" style="width:200px;">
                                <option value="0">组织机构</option>
                                {foreach name="$department_list" item="vo"}
                                <option value="{$vo['id']}" {if condition="input('department_id') == $vo['id']"}selected{/if}>
                                {for start="0" end="$vo['num']"}
                                |------
                                {/for}
                                {$vo['name']}
                                </option>
                                {/foreach}
                            </select> -->

                            <p style="margin-left: 10px;">姓　　名:</p><input class="form-control" name="name" value="{:input('get.name')}" placeholder="请输入姓名" AUTOCOMPLETE="off" style="width:200px;height:34px;">
                            <div class="input-group" style="display: flex; align-items: center; flex-wrap: wrap;">
                                <p>工　　号:</p><input class="form-control" name="job_number" value="{:input('get.job_number')}" placeholder="请输入工号" AUTOCOMPLETE="off" style="width:200px;height:34px;">

                                <p>月　　份:</p>
                                <input class="form-control lay_date" name="create_time" value="{$create_time}" placeholder="奖扣时间" AUTOCOMPLETE="off" style="width:200px;height:34px;">
                            </div>
                            <div class="input-group-btn" style="display: inline-block;">
                                <button type="submit" class="btn btn-default sreachs">
                                    <i class="fa fa-search"></i> 查询
                                </button>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="box-header with-border">
                    <div class="pull-left">
                        <a href="javascript:xls_explode();" class="btn btn-sm btn-primary"><i class="fa fa-cloud-upload"></i> 导出</a>
                    </div>

                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <!--<th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>-->
                            <th>月份</th>
                            <th>奖扣对象</th>
                            <th>工号</th>
                            <th>事件数</th>
                            <th>A分</th>
                            <th>B分</th>
                            <th>请假时长</th>
                        </tr>
                        {volist name="list_a" id="v"}
                        <tr>
                            <!--<td><input type="checkbox" name="id[]" value="{$v.id}" class="minimal checkbox"></td>-->
                            <!--<td>{:date('Y-m', $v['create_time'])}</td>-->
                            <td>{$v.prize_buckle_time}</td>
                            <td><a href="{:url('review/index', ['user_id'=>$v['u_id']])}">{$v.name}</a></td>
                            <td>{$v.job_number}</td>
                            <td>{$v.event_num}</td>
                            <td>{$v.integral_a}</td>
                            <td>{$v.integral_b}</td>
                            <td {if condition="$v.hour >0 || $v.day >0"}style="color:red;"{/if}>{$v.leave_time}</td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(function(){

        $(".select2").select2({language:"zh-CN"});

        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });

    var now = new Date();
    var yy = now.getFullYear(); //年
    var mm = now.getMonth() + 1; //月
    var dd = now.getDate(); //日
    var hh = now.getHours(); //时
    var ii = now.getMinutes(); //分
    var ss = now.getSeconds(); //秒
    var time = yy + "-";
    if (mm < 10) time += "0";
    time += mm + "-";
    if (dd < 10) time += "0";
    time += dd + " ";
    if (hh < 10) time += "0";
    time += hh + ":";
    if (ii < 10) time += '0';
    time += ii + ":";
    if (ss < 10) time += '0';
    time += ss;
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var nowtime = "{:date('Y-01-01 H:i:s',time())}";
        laydate.render({
            range:true,
            type:'month',
            elem: '.lay_date',
            // min: nowtime,
            max:time
        });
    });

    function xls_explode() {
        window.location.href = "{:url('Review/staff')}?" + $('#form1').serialize()+'&export=1';
        return false;
    }
</script>



<!-- 弹框样式引入 -->
<link rel="stylesheet" href="__STATIC__/global/an_tree_css/an_tree_css.css">
<!-- Modal 弹出层重写 部门单选  id="myModal_single"-->
<div class="modal fade" id="myModal_department_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" style="width:517px;height: 635px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">部门选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left" style="width:485px;">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body" style="width: 485px">
                        <div class="table-left" style="width: 100%;">
                            <div class="an_tree search_hide">

                            </div>
                            <div class="search_show" style="display: flex;  flex-direction: column;padding: 20px 10px;">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<style>
.a{
    flex-direction: row;
}
</style>
</div>
<!-- 部门弹窗操作 部门单选   -->
<script>
    var now_item_name;
    var now_item_id;
    $(".department_id_name").focus(function () {
        $('#myModal_department_single').modal('show');
        // double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $(".department_id");//节点
        // first_id = $("input[name='first_check_user_id']").val();//id值
        // user_type = 2;
    });

</script>
<!-- 树结构js操作 部门单选  -->
<script>
    $("#myModal_department_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_department_single").on("click", ".an_tree_txt", function () {
        $('#myModal_department_single').modal('hide');
        now_item_name.val($(this).html());
        now_item_id.val($(this).attr("data_id"));
    });
    $("#myModal_department_single").on("click", ".search_btn", function () {
        var item = $("#myModal_department_single .an_tree_txt");
        var search_name = $("#myModal_department_single input[name='search_user_name']").val();
        $("#myModal_department_single .search_show").html("");
        if(search_name == ""){
            $("#myModal_department_single .search_hide").show();
            $("#myModal_department_single .search_show").removeClass("an_tree");
        }else{
            $("#myModal_department_single .search_hide").hide();
            $("#myModal_department_single .search_show").show();
            var content = "";
            for (let i = 0; i < item.length; i++) {
                var name = item.eq(i).html();
                if (name.indexOf(search_name) != -1) {
                    content += item.eq(i).prop("outerHTML");
                }
                console.log(name);
            }
            $("#myModal_department_single .search_show").append(content)
        }
        
    });
</script>
<!-- 递归填充目录 部门单选  -->
<script>
    var department = "";
    $.ajax({
        type: 'get',
        url: "{:url('base/base_department_page')}",
        dataType:"json",
        async: false,
        success: function (data) {
            // eventList = JSON.parse(data);
            department = data;
        }
    })
    var an_tree = ergodic(department)
    $("#myModal_department_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>

{/block}
